<?php
declare (strict_types = 1);

namespace app\admin\validate;

use think\Validate;

class Goods extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [

        'goods_name' => 'require|max:100|unique:goods',
        'goods_price' => 'require',
        'goods_num' => 'require|number',
        'goods_logo' => 'require|fileExt:png,jpeg,jpg'
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'goods_name.require' => '商品名称不能为空',
        'goods_name.unique' => '商品名称不能重复',
        'goods_price.require' => '商品价格不能为空',
        'goods_num.require' => '商品数量不能为空',
        'goods_num.number' => '商品数量只能是纯数字',
        'goods_logo.require' => '商品图片必须上传',
        'goods_logo.fileExt' => '图片后缀只能是png、jpeg、jpg',

    ];
}
